package survivial;

import java.util.List;
import java.util.Random;

import tutorial.EventManager;
import tutorial.Tutorial;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;

public class BlockSmoke extends Block
{
	@SideOnly(Side.CLIENT)
	private Icon[] icons;

	protected BlockSmoke(int blockID)
	{
		super(blockID, Material.air);
		setTickRandomly(true);
	}

	@Override
	public boolean isAirBlock(World world, int x, int y, int z)
	{
		return true;
	}

	public boolean isOpaqueCube()
	{
		return false;
	}

	public boolean renderAsNormalBlock()
	{
		return false;
	}

	@SideOnly(Side.CLIENT)
	public Icon getIcon(int par1, int par2)
	{
		return null;
	}

	@SideOnly(Side.CLIENT)
	public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
	{
		// for (int i = 0; i < 2; i++)
		// {
		// par3List.add(new ItemStack(par1, 1, i));
		// }
	}

    @SideOnly(Side.CLIENT)
    @Override
    public void randomDisplayTick(World world, int x, int y, int z, Random rand) 
    {
    	double windMag = 0.1f;
    	
    	for(int i = 0; i < 0; i++)
    	{
	    	double velX = -0.5 + rand.nextDouble();
	    	double velY = rand.nextDouble();
	    	double velZ = -0.5 + rand.nextDouble();
			world.spawnParticle("smoke", x, y + 0.5, z, windMag * (velX), 0.1D, windMag * velZ);
			
			if (rand.nextFloat() > 0.5f)
			{
				int ox = -1 + rand.nextInt(3);
				int oy = -1 + rand.nextInt(3);
				int oz = -1 + rand.nextInt(3);
				
				x += ox;
				y += oy;
				z += oz;
				
				int blockID = world.getBlockId(ox, oy, oz);
				if (blockID <= 0)
				{
					//world.setBlock(x, y, z, Survivial.smoke.blockID, 0, 3);
				}
			}
    	}
    }

    
	private final Random _rand = new Random();

	/**
	 * Called whenever the block is added into the world. Args: world, x, y, z
	 */
	public void onBlockAdded(World par1World, int par2, int par3, int par4)
	{
		super.onBlockAdded(par1World, par2, par3, par4);
	}

	/**
	 * Called upon block activation (right click on the block.)
	 */
	public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
	{
		return true;
	}

	public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
	{
	}

	/**
	 * Called on server worlds only when the block has been replaced by a
	 * different block ID, or the same block with a different metadata value,
	 * but before the new metadata value is set. Args: World, x, y, z, old block
	 * ID, old metadata
	 */
	public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
	{
		super.breakBlock(par1World, par2, par3, par4, par5, par6);
	}

	public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
	{
	}

}
